using System;
using System.Reflection;

namespace time
{
    internal class Class_js
    {
        public static void Main()
        {
            Console.Write(GetA());
            Console.ReadLine();
        }

        private static string GetA()
        {
            //System.Type type = System.Type.GetTypeFromProgID("MSScriptControl.ScriptControl");
            //Object script = System.Activator.CreateInstance(type);
            //type.InvokeMember("language", BindingFlags.SetProperty, null, script, new Object[] { "JavaScript" });
            //StreamReader sr1 = new StreamReader("1.js");
            //string s = sr1.ReadToEnd();
            //type.InvokeMember("a", BindingFlags.InvokeMethod, null, script, new Object[] { s });
            //string strtemp = type.InvokeMember("Run", BindingFlags.InvokeMethod, null, script, new Object[] { "a" }).ToString();

            //return strtemp;

            System.Type type = System.Type.GetTypeFromProgID("MSScriptControl.ScriptControl");
            Object script = System.Activator.CreateInstance(type);
            type.InvokeMember("language", BindingFlags.SetProperty, null, script, new Object[] { "JavaScript" });
            type.InvokeMember("AddCode", BindingFlags.InvokeMethod, null, script, new Object[] { "function test(){ return new Date().getTime().toString()}" });

            return type.InvokeMember("Run", BindingFlags.InvokeMethod, null, script, new Object[] { "test" }).ToString();
        }
    }
}